/*
 * @Description: 
 * @Version: 1.0
 * @Author: wenbin
 * @Date: 2021-03-30 13:34:18
 * @LastEditors: wenbin
 * @LastEditTime: 2021-05-08 17:00:54
 * @FilePath: /magus-plugin/examples/middleware/index.js
 * Copyright (C) 2021 wenbin. All rights reserved.
 */

import Vue from 'vue'
import VueI18n from 'vue-i18n'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import magusUI from '../../packages/index'
import enElement from 'element-ui/lib/locale/lang/en'
import zhCNElement from 'element-ui/lib/locale/lang/zh-CN'
import '@examples/router/routerFilter'
import ElementLocale from 'element-ui/lib/locale'
import '../mock/index'
// import '@assets/less/index.less'
// 自定义组件
// import '@components'


Vue.prototype.$magusCloudApi = magusUI.exportApi;

let catchUtils = magusUI.exportApi.catchUtil;

if (!catchUtils.getLocalItem('language')) {
  catchUtils.setLocalItem('language', 'zh')
}

Vue.use(ElementUI);
Vue.use(magusUI)
Vue.use(VueI18n)


// 国际化
const i18n = new VueI18n({
  locale: catchUtils.getLocalItem('language') || 'zh', // 语言标识, 通过切换locale的值来实现语言切换,this.$i18n.locale
  messages: {
    zh: {
      ...magusUI.exportApi.lang.zhCN,
      ...zhCNElement
    }, // 中文语言包
    en: {
      ...magusUI.exportApi.lang.en,
      ...enElement
    }, // 英文语言包
  },
})

ElementLocale.i18n((key, value) => i18n.t(key, value))

export default i18n